package b3.widget.basic
{
	public class TimeFormat extends BasicWidget
	{
		private var m1:SpriteDigit;
		private var m2:SpriteDigit;
		private var s1:SpriteDigit;
		private var s2:SpriteDigit;
		private var ms1:SpriteDigit;
		private var ms2:SpriteDigit;
		
		public function TimeFormat(seconds:Number, FontClass:Class)
		{
			m1 = new SpriteDigit(0, FontClass);
			m2 = new SpriteDigit(0, FontClass);
			s1 = new SpriteDigit(0, FontClass);
			s2 = new SpriteDigit(0, FontClass);
			ms1 = new SpriteDigit(0, FontClass);
			ms2 = new SpriteDigit(0, FontClass);
			var colon1:SpriteDigit = new SpriteDigit(10, FontClass);
			var colon2:SpriteDigit = new SpriteDigit(10, FontClass);
			m2.x = 50;
			colon1.x = 100; 
			s1.x = 150;
			s2.x = 200;
			colon2.x = 250;
			ms1.x = 300;
			ms2.x = 350;
			addChild(m1);
			addChild(m2);
			addChild(colon1);
			addChild(s1);
			addChild(s2);
			addChild(colon2);
			addChild(ms1);
			addChild(ms2);
			time = seconds;
		}
		
		public function set time(seconds:Number):void
		{
			seconds = seconds >= 0 ? seconds : 0;  
			var temp:int = seconds * 100;
			ms2.digit = temp % 10;
			temp /= 10;
			ms1.digit = temp % 10;
			temp /= 10;
			s2.digit = temp % 10;
			temp /= 10;
			s1.digit = temp % 6;
			temp /= 6;
			m2.digit = temp % 10;
			temp /= 10;
			m1.digit = temp % 10;
		}

	}
}